<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>04运算符</title>
</head>
<body>
    <script>
        //Number('3')
        console.log(3>2);
        //如果比较运算符左右两边有数字,会转为数字再进行比较
        console.log('1'>2);
        console.log(1>'2');
        //如果比较运算符左右两边都是字符串,会比较编码值
        console.log('郭'>'伟');
       /*  '郭'.charCodeAt() 查看编码值 */
        console.log('郭'.charCodeAt())
        console.log('伟'.charCodeAt())

        //除法会根据实际结果显示运输结果
        console.log(3/2);//1.5
        console.log(3/3);//1

        let a = 3;
        let b = true;
        //松散比较运算符,只比较值,Number(true) = 1
        console.log(a==b)//true
        //严格比较运算符,先比较类型,再比较值 number ≠ boolean
        console.log(a===b)//false

        //Number() 将参数转换为数字,如果得不到数字的结果,会得到NaN(Not a Number)
        console.log(Number(true),typeof Number(true));//1 'number'
        console.log(Number('3'),typeof Number('3'));//3 'number'
        console.log(Number('你好'),typeof Number('你好'));//NaN 'number'

        //Boolean() 将参数转换为布尔值
        //如果参数为0,空字符串'',null,undefined,NaN,会返回false,其他返回true
        console.log(Boolean(0));
        console.log(Boolean(''));
        console.log(Boolean(null));
        console.log(Boolean(undefined));
        console.log(Boolean(NaN));
        console.log(Boolean(' '));
        console.log(Boolean('hhhhh'));

        let c = 0;
        console.log(c==0 ? 'Yes' : 'No');
        // = 赋值运算符
        console.log(c=0 ? 'Yes' : 'No');
    </script>
</body>
</html>